import request from '@/utils/request';
import settings from '../../../config/defaultSettings';

export interface LoginType {
  username: string;
  password: string;
}
export interface UserId {
  UserId: string;
}
/**
 * 获取登录Token
 * @param params
 * @returns
 */
export async function GetUserToken(params: LoginType) {
  console.log(`${settings.prefixUrl}`);
  return request(`${settings.prefixUrl}/auth/login`, {
    method: 'POST',
    data: params,
  });
}

export async function GetReLoginToken(params: LoginType) {
  console.log(`${settings.prefixUrl}`);
  return request(`${settings.prefixUrl}/auth/reLogin`, {
    method: 'POST',
    data: params,
  });
}

export async function LogOut() {
  return request(`${settings.prefixUrl}/auth/logout`, {
    method: 'DELETE',
  });
}
/**
 * 获取个人信息(带上token直接获取)
 * @param params
 * @returns
 */
export async function GetUserInfo() {
  return request(`${settings.prefixUrl}/system/user/viewBaseInfo`, {
    method: 'GET',
    // data: params,
  });
}

export async function userList(params: any) {
  return request(`${settings.prefixUrl}/system/user/userList`, {
    method: 'POST',
    data: params,
  });
}

/**
 * 获取角色
 * @param params
 * @returns
 */
export async function GetUserRoleByUserId(params: UserId) {
  return request('/mmsapi/authorityservice/UserRoleQuery/GetUserRoleByUserId', {
    method: 'POST',
    data: params,
  });
}

/**
 * 获取权限
 * @param params
 * @returns
 */
export async function GetPersmissionByUserId(params: UserId) {
  return request('/mmsapi/authorityservice/UserQuery/GetPersmissionByUserId', {
    method: 'POST',
    data: params,
  });
}
